<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="hg-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="/hg-layui-admin-ui/css/font.css">
    <link rel="stylesheet" href="/hg-layui-admin-ui/lib/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/hg-layui-admin-ui/lib/admin/admin.css" media="all">
    <link rel="stylesheet" href="/hg-layui-admin-ui/lib/Scrollbar/jquery.scrollbar.css">
    <script type="text/javascript" src="/hg-layui-admin-ui/lib/admin/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="/hg-layui-admin-ui/lib/Scrollbar/jquery.scrollBar.js"></script>
    <script type="text/javascript" src="/hg-layui-admin-ui/lib/layui/layui.js"></script>
    <script type="text/javascript" src="/hg-layui-admin-ui/lib/admin/admin.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body class="layui-body-content">
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">
            <i class="iconfont">&#xe6ac;</i>课程数据表
            <span class="layui-layout-right">
                    <a href="javascript:;" hg-event="fullscreen">
                        <i class="layui-icon layui-icon-screen-full"></i>
                    </a>
                </span>
        </div>
        <div class="layui-card-body">
            <table class="layui-hide" id="test" lay-filter="test"></table>
        </div>
    </div>
</div>
</body>
<script>
    //打分
    function edit(obj) {
        //obj通过行tool修改-lay-event
        var row = obj ? obj : hg.table.datatable('test', 'getSelected');
        if (row) {
            hg.open('编辑授课' + row.data.name, '/teacher/edit.html?id='+
                row.data.id + '&score=' + row.data.score
                , 600, 400);
        } else {
            hg.msg('请选中一行数据，再操作！');
        }
    }
    var tableCols = [
        [{
            field: 'course',
            width: '10%',
            title: '课程',
            minWidth: 100,
            templet: function (d) {
                return d.teaching.course.name
            }
        }, {
            field: 'course',
            width: '10%',
            title: '学生',
            minWidth: 100,
            templet: function (d) {
                return d.student.name
            }
        }, {
            field: 'number',
            width: '10%',
            title: '学号',
            minWidth: 100,
            templet: function (d) {
                return d.student.number
            }
        }, {
            field: 'teacher',
            width: '10%',
            title: '授课教师',
            minWidth: 100,
            style: 'color: #ff5722;',
            sort: true,
            templet: function (d) {
                return d.teaching.teacher.name
            }
        }, {
            field: 'semester',
            width: '20%',
            title: '学期',
            minWidth: 100,
            templet: function (d) {
                return d.teaching.semester
            }
        }, {
            field: 'score',
            width: '10%',
            title: '分数',
            minWidth: 100
        }, {
            field: 'state',
            width: '10%',
            title: '授课状态',
            templet: function (d) {
                return d.teaching.state == 0?'正在授课' : '停止授课';
            }
        }, {
            field: 'right',
            width: '10%',
            title: '操作',
            templet: function (d) {
                return '<a class="layui-btn layui-btn-xs" lay-event="edit">打分</a>'
            }
        }]
    ];
    var toolbar = [
    ];

    //从另一个html页面传来的值，在这里获取
    var url = location.search; //获取url中"?"符后的字串 ('?endId=.....')
    var theRequest = new Object();
    if ( url.indexOf( "?" ) != -1 ) {
        var str = url.substr( 1 ); //substr()方法返回从参数值开始到结束的字符串；
        var strs = str.split( "&" );
        for ( var i = 0; i < strs.length; i++ ) {
            theRequest[ strs[ i ].split( "=" )[ 0 ] ] = ( strs[ i ].split( "=" )[ 1 ] );
        }
    }
    var data = {'teachingId' : decodeURI(theRequest.teachingId)};
    var table = hg.table.datatable('test', '选课信息管理', 'getElectivesByTeaching', data, tableCols, toolbar, true, 'full-210', ['filter', 'print', 'exports']);

</script>

</html>